﻿using Newtonsoft.Json;
using RentHouse.DTO;
using RentHouse.IService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace RentHouse.Admin.Controllers
{
    public class RolesController : Controller
    {

        IRolesService roles;
        public RolesController(IRolesService roles)
        {
            this.roles = roles;

        }


        //返回全部信息
        public string GetAll(int page, int limit)
        {
            //Response.Headers.Add("Access-Control-Allow-Origin", "*");

            return JsonConvert.SerializeObject(roles.GetList(page, limit));

        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="adminUserDTO"></param>
        /// <returns></returns>
        public string Create(RolesDTO rolesDTO)
        {

            //Response.Headers.Add("Access-Control-Allow-Origin", "*");

            return roles.Create(rolesDTO);

        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="adminUserDTO"></param>
        /// <returns></returns>
        public string Delete(RolesDTO rolesDTO)
        {

            //Response.Headers.Add("Access-Control-Allow-Origin", "*");

            return roles.Delete(rolesDTO);
        }

        /// <summary>
        /// 用户修改
        /// </summary>
        /// <param name="adminUserDTO"></param>
        /// <returns></returns>
        public string Update(RolesDTO rolesDTO)
        {

            //Response.Headers.Add("Access-Control-Allow-Origin", "*");

            return roles.Update(rolesDTO);
        }



    }
}